import request from '@/utils/request'
import { praseStrEmpty } from "@/utils/init";
const user = {

  listUser(query) {
    return request({
      url: 'admin/sys-user/page/'+query.pageNum+'/'+query.pageSize,
      method: 'get',
      params: query

    })
  },


  getUser(id) {
    return request({
      url: 'admin/sys-user/get/'+ praseStrEmpty(id),
      method: 'get'
    })
  },
  delUser(ids) {
    return request({
      url: 'admin/sys-user/remove/'+ids,
      method: 'delete'
    })
  },
  addUser(data) {
    return request({
      url: 'admin/sys-user/create',
      method: 'post',
      data: data
    })
  },
  updateUser(data) {
    return request({
      url: 'admin/sys-user/update',
      method: 'put',
      data: data
    })
  },


  resetUserPwd(id, password) {
    const data = {
      id,
      password
    }
    return request({
      url: 'admin/sys-user/change/password',
      method: 'put',
      data: data
    })
  },
  /**
   * 更改状态
   * @param id
   * @param status
   */
  changeUserStatus(id, status) {
    const data = {
      id,
      status
    }
    return request({
      url: 'admin/sys-user/change/status',
      method: 'put',
      data: data
    })
  },
  importTemplate() {
    return request({
      url: 'admin/sys-user/token',
      method: 'get'
    })
  },
  exportUser() {
    return request({
      url: 'admin/sys-user/token',
      method: 'get'
    })
  },
  updateUserPwd(oldPassword, newPassword) {
    const data = {
      oldPassword,
      newPassword
    }
    return request({
      url: 'admin/sys-user/profile/reset/password',
      method: 'put',
      params: data
    })
  },
// 用户头像上传
 uploadAvatar(data) {
    return request({
      url: '/admin/sys-user/profile/avatar',
      method: 'post',
      data: data
    })
  },
  /**
   * 修改用户个人信息
   * @param data
   */
  updateUserProfile(data) {
    return request({
      url: '/admin/sys-user/profile',
      method: 'put',
      data: data
    })
  },
  getUserProfile() {
    return request({
      url: '/admin/sys-user/profile',
      method: 'get'
    })
  },

}

export default user
